//--------------------------------------------------------------------
#ifndef _dkexpression_h
#define _dkexpression_h
//--------------------------------------------------------------------

//char * dkgettoken( char *expstr, char *t );	// get token from expstr into t


typedef struct _dkexpression{
	void *data;				// it's important that this struct is aligned on word boundary so value can go negative ?
	uint8_t numdimensions;		// # of dimensions in this array
	uint16_t *dimensions;		// malloc()d by DIM to have enough space for all dimensions
	uint16_t type;
}dkexpression;



extern uint8_t class_ident( char *c );
extern uint8_t class_binary( char *c );
extern uint8_t greater_precedence( char *a, char *b );
extern uint8_t op_precedence( char *a );		// return numeric value of operator's precedence (higher value = higher precedence)
extern dkexpression *binary_op( dkexpression *expr1, char *op, dkexpression *expr2 );


extern dkexpression *expression( char *expressionstring );
extern dkexpression *item( void );
extern dkexpression *expr( dkexpression *e1, char *op1 );

extern uint8_t class_unary( char *c );
extern dkexpression *unary_op( char *op, dkexpression *expr );


extern dkexpression *dkidentifier( char *t );

// allocate memory for a new dkexpression and set it to empty values
extern dkexpression *dknewexp( void );
// free dkexpression e and the memory allocated to 'value' if non-integer
extern void dkexpfree( dkexpression *e );

// return value of e as uint16_t and set *exptype to indicate what type of expression e is (0 if unable to convert to int)
//extern uint16_t dkexpint( dkexpression *e, uint16_t *exptype );

extern double dkexptofloatsingle( dkexpression *e );
extern double dkexptofloatdouble( dkexpression *e );
extern uint16_t dkexptoint( dkexpression *e );
extern uint8_t dkexptobyte( dkexpression *e );


extern char *expstr;
//--------------------------------------------------------------------
#endif	// !_dkexpression_h
//--------------------------------------------------------------------

